package com.linxz.ui.spraycarview;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.RadioGroup;

import androidx.appcompat.widget.AppCompatRadioButton;

public class ClearRadioButton extends AppCompatRadioButton {
    public ClearRadioButton(Context context) {
        super(context);
    }

    public ClearRadioButton(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ClearRadioButton(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }
    @Override
    public void toggle() {
        if (isChecked()) {
            if(getParent()!=null){
                if(getParent() instanceof RadioGroup){
                    ((RadioGroup) getParent()).clearCheck();
                }
            }
        }else {
            setChecked(!isChecked());
        }

    }



}
